import request from '@/utils/request'

// 查询考勤数据列表
export function getAttendancesList(params) {
  console.log(params)
  return request.get('/attendances', params)
}

// 根据用户id和月份查询已归档的考勤明细
export function getAtteArchiveDetail(data) {
  return request.get(`/attendances/archive/${data.userId}/${data.yearMonth}`)
}

// 编辑用户的考勤记录
export function updateAttendance(data) {
  return request.put(`/attendances/${data.userId}`, data)
}

// 归档历史列表
export function getArchivingList(params) {
  return request('/attendances/reports/year', params)
}

export function getArchivingCont(params) {
  return request({
    url: `/attendances/reports/${params.atteArchiveMonthlyId}`,
    params
  })
}

export function importArchive(data) {
  return request({
    url: '/archive/atte/export',
    method: 'post',
    data
  })
}
// 提醒接口
export function notify() {
  return request({
    url: '/notify/mail',
    method: 'post'
  })
}

// 月度考勤记录归档
export function archives(params) {
  return request({
    url: '/attendances/archives',
    params
  })
}

// 新建考勤报表
export function newReports(params) {
  return request({
    url: '/attendances/newReports',
    params
  })
}

export function information() {
  return request({})
}

export function pay() {
  return request({})
}

// 获取月考勤报表数据
export function reportFormList(params) {
  return request({
    url: '/attendances/reports',
    params
  })
}

// 保存或者更新请假规则
export function leaveSave(data) {
  return request.put('/cfg/leave', data)
}

// 根据部门查询请假规则设置
export function getLeave(data) {
  return request.post('/cfg/leave/list', data)
}

// 保存考勤扣款规则
export function deductionsSave(data) {
  return request.put('/cfg/deduction', data)
}

// 根据部门查询考勤扣款规则
export function getDeductions(data) {
  return request.post('/cfg/ded/list', data)
}

// 根据部门保存考勤加班规则
export function overtimeSave(data) {
  return request.put('/cfg/extDuty', data)
}

// 根据部门查询考勤加班规则
export function getOvertime(data) {
  return request.post('/cfg/extDuty/item', data)
}

// 保存考勤设置
export function attendanceSave(data) {
  return request.put('/cfg/atte', data)
}

// 根据部门id查询考勤设置
export function getAttendance(data) {
  return request.post('/cfg/atte/item', data)
}

export function fileUpdate(data) {
  return request({
    url: `/employee/archives/${data.month}`,
    method: 'put',
    data
  })
}
